//express_demo.js 文件
const express = require("express");
const multer = require("multer");
const path = require("path");
const config = require("./config.js");

var app = express();


// // 跨域请求设置
// app.use(function (req, res, next) {
//     res.header("Access-Control-Allow-Origin", "*");
//     res.header("Access-Control-Allow-Headers", "*");
//     res.header("Access-Control-Allow-Methods", "DELETE,PUT,POST,GET,OPTIONS");
//     // 这里加上"Access-Control-Expose-Headers", "Authorization"前端才能读取token
//     res.header("Access-Control-Expose-Headers", "Authorization");
//     if (req.method == "OPTIONS") res.sendStatus(200);
//     else next();
// });


app.use(express.static(path.join(__dirname, "public")));

app.get("/", function (req, res) {
    res.send("Hello World!");
});

app.use("/login", require("./route/CityIndex.js"));

app.listen(config.port, () => {
    console.log(`server startup on http://localhost:${config.port}`);
});

